


import java.util.*;

/**
 * @author seberm
 */
public class blackjack_old {

    /**
     * @param args Array witch command line arguments
     */
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
	   Random ran = new Random();
	   int rNum = 0; // Random number
	   int sNum; // Total SUM


	   // Start the game
	   printHelp();
	   
	   do {
		   System.out.println("\n\nHra zacala...");
		   sNum = 0;
		   
		   do {
			rNum = ran.nextInt(10) + 2; // Range 2 -> 11

			sNum += rNum;

			System.out.println("\nVytahl jste si cislo: " + rNum);

			// Over 21?
			if (sNum > 21) {
				System.out.println("\n#####################\n" +
						"Game over - YOU LOST!\n" +
						"#####################");

				sNum = 0;
				break; // New game?
			} else if (sNum ==  21) {
				System.out.println("\n#####################\n" +
						"YOU'RE A WINNER! \n" +
						"#####################");

				sNum = 0;
				break;
			}

			
			System.out.println("Vas aktualni soucet karet je " + sNum);
			System.out.println("Prejete si dalsi kartu? (N): ");
		   } while (sc.next().charAt(0) == 'N');


		   System.out.println("Hra byla ukoncena se souctem karet: " + sNum);
		   System.out.println("Ukonceni hry - E > vase volba: ");

	   } while (sc.next().charAt(0) != 'E');

	   System.exit(0);
    }



	/**
	 * Prints the help of application
	 */
	public static void printHelp () {
		String help;
		help = new String ("Vitejte ve hre BlackJack (Oko bere; 21)\n" +
			   "Napoveda:\n" +
			   "Mimo kolo: Ukoncit hru - E, dalsi kolo - R\n" +
			   "Behem kola: Dalsi karta - N, ukoncit kolo - F\n\n");

		System.out.print(help);
	}

}
